<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:DiagramDesigner">

    <Style TargetType="local:ResizeThumb">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ResizeThumb">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Thumb x:Name="thumb"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="MoveThumb" TargetType="Thumb">
        <Rectangle Fill="Transparent"/>
    </ControlTemplate>

    <Style TargetType="local:MoveThumb">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:MoveThumb">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Thumb x:Name="thumb" Template="{StaticResource MoveThumb}"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:RotateThumb">
        <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:RotateThumb">
                    <Grid Width="30" Height="30">
                        <Path Fill="#AAD0D0DD" Stretch="Fill" Data="M 50,100 A 50,50 0 1 1 100,50 H 50 V 100"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
    </Style>

    <Style TargetType="Shape" x:Key="ThumbCorner">
        <Setter Property="Stroke" Value="#FFC8C8C8" />
        <Setter Property="StrokeThickness" Value=".5" />
        <Setter Property="Width" Value="7" />
        <Setter Property="Height" Value="7" />
        <Setter Property="Margin" Value="-2" />
        <Setter Property="Fill">
            <Setter.Value>
                <RadialGradientBrush Center="0.2, 0.2" GradientOrigin="0.2, 0.2" RadiusX="0.8" RadiusY="0.8">
                    <GradientStop Color="White" Offset="0.0" />
                    <GradientStop Color="Gray" Offset="0.8" />
                </RadialGradientBrush>
            </Setter.Value>
        </Setter>
    </Style>
   
    
    <Style TargetType="local:ResizeRotateChrome">
        <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ResizeRotateChrome">
                    <Grid>
                        <Grid Opacity="0" Margin="-3">
                            <local:RotateThumb Width="14"
                             Height="14"
                             Margin="0,-30,0,0"
                             Cursor="Hand"
                             VerticalAlignment="Top"
                             HorizontalAlignment="Center"/>
                            <local:ResizeThumb Height="3"
                             Cursor="SizeNS"
                             VerticalAlignment="Top"
                             HorizontalAlignment="Stretch"/>
                            <local:ResizeThumb Width="3"
                             Cursor="SizeWE"
                             VerticalAlignment="Stretch"
                             HorizontalAlignment="Left"/>
                            <local:ResizeThumb Width="3"
                             Cursor="SizeWE"
                             VerticalAlignment="Stretch"
                             HorizontalAlignment="Right"/>
                            <local:ResizeThumb Height="3"
                             Cursor="SizeNS"
                             VerticalAlignment="Bottom"
                             HorizontalAlignment="Stretch"/>
                            <local:ResizeThumb Width="7"
                             Height="7"
                             Margin="-2"
                             Cursor="SizeNWSE"
                             VerticalAlignment="Top"
                             HorizontalAlignment="Left"/>
                            <local:ResizeThumb Width="7"
                             Height="7"
                             Margin="-2"
                             Cursor="SizeNESW"
                             VerticalAlignment="Top"
                             HorizontalAlignment="Right"/>
                            <local:ResizeThumb Width="7"
                             Height="7"
                             Margin="-2"
                             Cursor="SizeNESW"
                             VerticalAlignment="Bottom"
                             HorizontalAlignment="Left"/>
                            <local:ResizeThumb Width="7"
                             Height="7"
                             Margin="-2"
                             Cursor="SizeNWSE"
                             VerticalAlignment="Bottom"
                             HorizontalAlignment="Right"/>
                            <local:MoveThumb Margin="3"/>
                        </Grid>
                        <Grid IsHitTestVisible="False" Opacity="1" Margin="-3">
                            <Rectangle StrokeThickness="1" Margin="1" Stroke="Gray"/>
                            <Line StrokeThickness="1" X1="0" Y1="0" X2="0" Y2="20" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,-19,0,0" Stroke="Gray"/>
                            <Ellipse Style="{StaticResource ThumbCorner}" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="-1,-20,0,0"/>
                            <Ellipse Style="{StaticResource ThumbCorner}" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                            <Ellipse Style="{StaticResource ThumbCorner}" HorizontalAlignment="Right" VerticalAlignment="Top"/>
                            <Ellipse Style="{StaticResource ThumbCorner}" HorizontalAlignment="Left" VerticalAlignment="Bottom"/>
                            <Ellipse Style="{StaticResource ThumbCorner}" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
